import Vue from 'vue';
import Router from 'vue-router';
import Home from '@/pages/home/home.vue';
import Search from '@/pages/search/search.vue';
import Register from '@/pages/register/register.vue';
import Login from '@/pages/login/login.vue';
import User from '@/pages/user/user.vue';
import Trend from '@/pages/user/components/children/trend.vue';
import Answer from '@/pages/user/components/children/answer.vue';
import Article from '@/pages/user/components/children/article.vue';
import Ask from '@/pages/user/components/children/ask.vue';
Vue.use(Router)
const router = new Router({
  mode:'history',
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home
    },
    {
      path:'/user',
      name:'user',
      component:User,
      children:[
        {
          path:'',
          component:Trend
        },
        {
          path:'trend',
          name:'trend',
          component:Trend
        },
        {
          path:'answer',
          name:'answer',
          component:Answer
        },
        {
          path:'article',
          name:'article',
          component:Article
        },
        {
          path:'ask',
          name:'ask',
          component:Ask
        }
      ]
    },
    {
      path: '/search',
      name: 'search',
      component: Search
    },
    {
      path: '/register',
      name: 'register',
      component: Register
    },{
      path: '/login',
      name: 'login',
      component: Login
    }
  ]
});
router.beforeEach((to,from,next) => {
  console.log('触发了beforeEach函数!');
  next();
})
export default router;
